﻿Public NotInheritable Class BrowserManager

    Private Shared _settings As New BrowserSettings
    Public Shared Sub SetSettings(ByVal settings As BrowserSettings)
        _settings = settings
    End Sub

    Public Shared Sub OpenUri(ByVal uri As Uri)

        Try
            If _settings.Path IsNot Nothing AndAlso _settings.Path.Trim <> "" Then

                Dim args = _settings.Args.Replace("{url}", uri.ToString)
                args = args.Replace("{live_id}", "")
                args = args.Replace("{station_id}", "")
                args = args.Replace("{title}", "")
                args = args.Replace("{station_name}", "")

                Process.Start(_settings.Path, args)
            Else
                Process.Start(uri.ToString)
            End If
        Catch ex As Exception
            ' Ignore
        End Try
    End Sub

    Public Shared Sub OpenUri(ByVal program As LiveProgram)

        Try

            If _settings.Path IsNot Nothing AndAlso _settings.Path.Trim <> "" Then

                Dim args = _settings.Args.Replace("{url}", program.Uri.ToString)
                args = args.Replace("{live_id}", program.Id)
                args = args.Replace("{station_id}", program.Station.Id)
                args = args.Replace("{title}", program.Title)
                args = args.Replace("{station_name}", program.Station.Name)

                Process.Start(_settings.Path, args)
            Else
                Process.Start(program.Uri.ToString)
            End If
        Catch ex As Exception
            ' Ignore
        End Try
    End Sub

    Private Sub New()
    End Sub
End Class
